{extend name="platform/base" /}
{block name="resources"/}
<link rel="stylesheet" type="text/css" href="ADMIN_CSS/member_list.css" />
<script type="text/javascript" src="__STATIC__/My97DatePicker/WdatePicker.js"></script>
<style>
.table>tbody#list>tr>td>img{max-height:60px;}
.border-gray{border-color: #f1f1f1}
.border-solid{border-width:1px; border-style: solid;}
.gray{color: #999;}
.order-count{margin-right:20px;}
</style>

{/block}

 {block name="main"}
 
	<div class="bg-white panel-body border-solid border-gray">
		<div class="col-sm-12">会员信息</div>
		<div class="row panel-body">
			<div class="col-sm-2">会员账号：<span class="gray">{$member_detail['user_info']['user_name']}</span></div>
			<div class="col-sm-2">会员等级：<span class="gray">{$member_detail['level_name']}</span></div>
<!-- 			<div class="col-sm-2">会员等级：<span class="gray">{$member_detail['level_name']}</span></div> -->
			<div class="col-sm-2"></div>
			<div class="col-sm-2"></div>
		</div>
		<div class="row b-t border-gray" style="margin-bottom: 12px;"></div>
		<div class="col-sm-12">账户信息</div>
		<div class="row panel-body">
			<div class="col-sm-2">当前余额：<span class="gray">{$member_detail['balance']}</span></div>
			<div class="col-sm-2">当前积分：<span class="gray">{$member_detail['point']}</span></div>
			<!-- <div class="col-sm-2">购物币：<span class="gray">{$member_detail['coin']}</span></div> -->
			<div class="col-sm-2"></div>
			<div class="col-sm-2"></div>
		</div>
	</div>

<div class="row padder-v">
		<div class="col-sm-5"></div>
		<div class="col-sm-2" >
			<div class="input-group">
				<input type="text" id='startDate' placeholder="请选择开始日期" class="input-sm form-control" onclick="WdatePicker()"/>
			</div>
		</div>
		<div class="col-sm-2" >
			<div class="input-group">
			<input type="text" id='endDate' placeholder="请选择结束日期" class="input-sm form-control" onclick="WdatePicker()" />

			</div>
		</div>
		<div class="col-sm-2" >
			<select id="account_type" class="input-sm form-control" >
				<option value="">请选择账户类型</option>
				<option value="1">积分</option>
				<option value="2">余额</option>
			</select>
		</div>
		<div class="col-sm-1">
			<button class="btn btn-sm btn-default" type="button"
				onclick="search()">搜索</button>
		</div>
</div>
<section class="panel panel-default">
	<div class="table-responsive">
		<table class="table table-striped b-light text-sm">
			<colgroup>
				<col width="4%">
				<col width="18%">
				<col width="14%">
				<col width="12%">
				<col width="12%">
				<col width="14%">
				<col width="20%">
			</colgroup>
			<thead>
				<tr>
					<th width="20"><input type="checkbox"></th>
					<th class="left">类别</th>
					<th class="left">产生方式</th>
					<th class="right">数量</th>
					<th class="right"></th>
					<th class="left">描述</th>
					<th class="center">时间</th>
				</tr>
			</thead>
			<tbody id="list">
				<tr></tr>
			</tbody>
		</table>
		
		<!-- <div class="padder-v b-t border-gray" style="padding-bottom: 30px;">
			<div class="col-sm-10"> </div>
			<div class="col-sm-1">积分：<span class="gray" id="point">0</span></div>
			<div class="col-sm-1">余额：<span class="gray" id="balance">0.00</span></div>
		</div> -->
		
		<input type="hidden" id="member_id" value="{$member_id}"/>
	</div>
	{include file="platform/page" /}
</section>



{/block}
 
{block name="script"}
<script type="text/javascript">

// 积分统计和余额统计
var integral_count,balance_count;

$(function(){
	search();
})

function search(){
	LoadingInfo(1);
	loadCount();
}

/*
 * 统计数据
 */
function loadCount(){
	
	var account_type = $("#account_type").val();
	var start_date = $("#startDate").val();
	var end_date = $("#endDate").val();
	var member_id = $("#member_id").val();
	
	$.ajax({
		type : "post",
		url : "{:__URL('PLATFORM_MAIN/member/getMemberAccountCount')}",
		async : false,
		data : { 
			 "account_type" : account_type, 
			 "start_date" : start_date, 
			 "end_date" : end_date,
			 "member_id" : member_id
		},
		success : function(data) {
			integral_count = data['integral_count'];
			balance_count = data['balance_count'];
		}	
	});
}

	
	function LoadingInfo(pageIndex) {
	
		var account_type = $("#account_type").val();
		var start_date = $("#startDate").val();
		var end_date = $("#endDate").val();
		var member_id = $("#member_id").val();
		
		$.ajax({
			type : "post",
			url : "{:__URL('PLATFORM_MAIN/member/memberAccountRecords')}",
			async : true,
			data : {
				"pageIndex" : pageIndex, 
				"start_date" : start_date,
				"end_date" : end_date,
				"account_type" : account_type,
				"member_id" : member_id,
			},
			success : function(data) {
				//console.log(data);
				var html = '';
				$("#total_count_num").text(data["total_count"]);
				$("#page_count_num").text(data["page_count"]);
				$("#page_count").val(data["page_count"]);
				$("#pageNumber a").remove();
				if (data["data"].length > 0) {
					for (var i = 0; i < data["data"].length; i++) {
						html += '<tr>';
						html += '<td><div class="cell"><label ><input name="sub" type="checkbox" value="'+ data["data"][i]["id"]+'" ></label></div></td>';
						html += '<td class="left">' + data["data"][i]["account_type_name"] + '</td>';
						html += '<td class="left">' + data["data"][i]["type_name"] + '</td>';
						html += '<td class="right">'+ data["data"][i]["number"] +'</td>';
						html += '<td class="center"></td>';
						html += '<td class="left">' + data["data"][i]["text"] + '</td>';
						html += '<td class="center">' + timeStampTurnTime(data["data"][i]["create_time"]) + '</td>';
						html += '</tr>';
					}
					html += '<tr>';
						html += '<td colspan="8" class="right">';
							html += '<span class="order-count">余额统计：'+ balance_count.toFixed(2) +'元</span>';
							html += '<span class="order-count">积分统计：'+ integral_count +'</span>';
						html += '</td>';
					html += '</tr>';
					
				} else {
					html += '<tr align="center"><td colspan="9" style="text-align:center;">暂无符合条件的账户明细数据记录</td></tr>';
				}
				$("#list").html(html);
 					var totalpage = $("#page_count").val();
				if (totalpage == 1) {
					changeClass("all");
				}
				var $html = pagenumShow(jumpNumber,totalpage,{$pageshow})
				$("#pageNumber").append($html);
				
			}
		});
	}
	//全选
	function CheckAll(event){
		var checked = event.checked;
		$(".style0list tbody input[type = 'checkbox']").prop("checked",checked);
	}
	$("#search_text").keypress(function(e){
		if(e.keyCode == 13){
			LoadingInfo(1);
		}
	});
</script>
{/block}
